package com.example.comiccenter.controller;


import com.example.comiccenter.domain.Chapter;
import com.example.comiccenter.domain.Comic;
import com.example.comiccenter.service.ChapterService;
import com.example.comiccenter.utils.ResultData;
import com.example.comiccenter.utils.SearchBean;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("chapter")
public class ChapterController {

    @Resource
    private ChapterService chapterService;

    @PostMapping("/selectChapter")
    public ResultData addComic(@RequestBody SearchBean<Chapter> searchBean){
//        System.out.println("查询comic："+searchBean);
        return chapterService.getAllChapter(searchBean);
    }

    //添加comic
    @PostMapping("/addChapter")
    public ResultData addChapter(@RequestBody Chapter chapter){
//        System.out.println("插入chapter："+chapter);
        return chapterService.addChapter(chapter);
    }

    //删除chapter
    @PostMapping("/deleteChapter")
    public ResultData deleteChapter(@RequestBody Chapter chapter){
//        System.out.println("删除chapter："+chapter);
        return chapterService.deleteChapter(chapter);
    }

    //更新chapter
    @PostMapping("/updateChapter")
    public ResultData updateChapter(@RequestBody Chapter chapter){
//        System.out.println("修改chapter："+chapter);
        return chapterService.updateChapter(chapter);
    }

}
